package com.bckj.fastboot.core.extra.mongo;

import com.bckj.fastboot.core.lang.model.PageResult;
import com.mongodb.client.result.UpdateResult;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.data.mongodb.core.query.UpdateDefinition;
import org.springframework.data.repository.NoRepositoryBean;

import java.util.Collection;
import java.util.List;

/**
 * IMongoRepository
 *
 * @author wfc
 * @date 2025/11/11 16:41
 **/
@NoRepositoryBean
public interface IMongoRepository<Entity, ID> {


    boolean save(Entity entity);

    boolean saveBatch(Collection<Entity> entities);

    boolean updateById(Entity entity);

    boolean updateBatchById(Collection<Entity> entities);

    UpdateResult updateFirst(Query query, Update update);

    UpdateResult updateMulti(Query query, UpdateDefinition update);

    boolean removeById(ID id) ;

    Entity findById(ID id);

    <T> T findById(ID id, Class<T> entityClass);

    <T> List<T> find(Query query);

    <T> List<T> find(Query query, Class<T> entityClass);

    <T> PageResult<T> page(Pageable pageable, Query query);

    <T> PageResult<T> page(Pageable pageable, Query query, Class<T> entityClass);

}
